import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/6 13:22
 */

public class Solution {
    int[] tmp;

    public int reversePairs(int[] record) {
        int n = record.length;
        tmp = new int[n];
        return MergeSort(record, 0, n - 1);
    }

    private int MergeSort(int[] nums, int left, int right) {
        if (left >= right) return 0;
        int ret = 0;

        //中点元素
        int mid = (left + right) / 2;

        //左半部分的数目+右半部分的数目
        ret += MergeSort(nums, left, mid);
        ret += MergeSort(nums, mid + 1, right);

        //一左一右的数目
        int p1 = left, p2 = mid + 1, i = 0;
        while (p1 <= mid && p2 <= right) {
            if (nums[p1] <= nums[p2]) {
                tmp[i++] = nums[p1++];
            } else {
                ret += mid - p1 + 1;
                tmp[i++] = nums[p2++];
            }
        }
        while (p1 <= mid) tmp[i++] = nums[p1++];
        while (p2 <= right) tmp[i++] = nums[p2++];
        for (int j = left; j <= right; j++) {
            nums[j] = tmp[j - left];
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int len = in.nextInt();
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.reversePairs(nums));
        }
    }
}